from datetime import datetime
from pydantic import Field, ConfigDict
from enum import IntEnum
from .base import BaseSchema

class WarehouseStatus(IntEnum):
    """仓库状态枚举"""
    DISABLED = 0
    ENABLED = 1

class WarehouseBase(BaseSchema):
    """仓库基础模型"""
    name: str = Field(..., description="仓库名称", max_length=255)
    address: str | None = Field(None, description="仓库地址", max_length=500)
    status: WarehouseStatus = Field(
        default=WarehouseStatus.ENABLED,
        description="仓库状态：1-正常，0-停用"
    )

    model_config = ConfigDict(
        json_schema_extra={
            "example": {
                "name": "主仓库",
                "address": "北京市朝阳区xxx街道",
                "status": 1
            }
        }
    )

class WarehouseCreate(WarehouseBase):
    """创建仓库请求模型"""
    pass

class WarehouseUpdate(BaseSchema):
    """更新仓库请求模型"""
    name: str | None = Field(None, description="仓库名称", max_length=255)
    address: str | None = Field(None, description="仓库地址", max_length=500)
    status: WarehouseStatus | None = Field(
        None,
        description="仓库状态：1-正常，0-停用"
    )

    model_config = ConfigDict(
        json_schema_extra={
            "example": {
                "name": "主仓库",
                "address": "北京市朝阳区xxx街道",
                "status": 1
            }
        }
    )

class WarehouseResponse(WarehouseBase):
    """仓库响应模型"""
    id: int
    create_at: datetime
    update_at: datetime

    model_config = ConfigDict(
        json_schema_extra={
            "example": {
                "id": 1,
                "name": "主仓库",
                "address": "北京市朝阳区xxx街道",
                "status": 1,
                "create_at": "2024-01-01T00:00:00",
                "update_at": "2024-01-01T00:00:00"
            }
        }
    ) 